#删除原容器
echo "begin stop and delete old ddns......"
docker stop ddns-cqj && docker rm ddns-cqj
echo "=======================rm over=============================="

# build images
echo "=======================start build ddns images=============================="
docker build -t ddns-cqj:1.0 docker/.
echo "build ddns app success..."

# check path
ddns_log_path="/home/docker/ddns/logs"
if [[ ! -d "ddns_log_path" ]]; then
    echo "ddns_log_path not exsits,create now."
    mkdir -p ${ddns_log_path}
else
    echo "ddns_log_path exsits,do not create."
fi

#build new ddns container
echo "=======================start build ddns container=============================="
docker run -d \
--network host \
-v /home/docker/ddns/logs:/home/docker/ddns/logs \
--privileged=true \
--name ddns-cqj \
--restart=always \
ddns-cqj:1.0
echo "=======================build end.=============================="